package com.dragon.lib_log.log.level

import android.util.Log
import com.dragon.lib_log.LoggerLevel
import com.dragon.lib_log.log.ILogger


/***
 * @ClassName LogCatLogger
 * @Author Administrator
 * @description logcat日志打印
 * @date 2025/2/22
 */
class LogCatLogger : ILogger {
    private var isDebug = false
    private var TAG = ""
    private var saveUrl = ""
    private var loggerLevel = LoggerLevel.DEBUG
    private var loggerFormat = "%s------->%s"
    override fun v(tag: String, msg: String) {
        if (isDebug && loggerLevel.ordinal >= LoggerLevel.DEBUG.ordinal) {
            Log.v(TAG, String.format(loggerFormat, tag, msg))
        }
    }

    override fun d(tag: String, msg: String) {
        if (isDebug && loggerLevel.ordinal >= LoggerLevel.DEBUG.ordinal) {
            Log.d(TAG, String.format(loggerFormat, tag, msg))
        }
    }

    override fun i(tag: String, msg: String) {
        if (isDebug && loggerLevel.ordinal >= LoggerLevel.DEBUG.ordinal) {
            Log.i(TAG, String.format(loggerFormat, tag, msg))
        }
    }

    override fun w(tag: String, msg: String) {
        if (isDebug && loggerLevel.ordinal >= LoggerLevel.DEBUG.ordinal) {
            Log.w(TAG, String.format(loggerFormat, tag, msg))
        }
    }

    override fun e(tag: String, msg: String) {
        if (isDebug && loggerLevel.ordinal >= LoggerLevel.DEBUG.ordinal) {
            Log.e(TAG, String.format(loggerFormat, tag, msg))
        }
    }

    override fun setDebug(isDebug: Boolean) {
        this.isDebug = isDebug
    }

    override fun setLogTAG(tag: String) {
        this.TAG = tag
    }

    override fun setLoggerLevel(level: LoggerLevel) {
        this.loggerLevel = level
    }

    override fun setSaveUrl(url: String) {
        this.saveUrl = url
    }
}